import 'package:flutter/material.dart';
import 'package:flutter_fronter_service/page/CartPage.dart';
import 'package:flutter_fronter_service/page/CatePage.dart';
import 'package:flutter_fronter_service/page/MyHomePage.dart';
import 'package:flutter_fronter_service/page/indexPage.dart';

class Taps extends StatefulWidget {
  const Taps({super.key});

  @override
  State<Taps> createState() => _TapsState();
}

class _TapsState extends State<Taps>
{

  int _currentIndex = 0;
  final List<Widget> _pages = [IndexPage(),CatePage(),CartPage(),MyHomePage()];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      drawerEnableOpenDragGesture: true, //作用：允许手势滑动打开抽屉
      bottomNavigationBar: BottomNavigationBar(
        iconSize: 25,
        selectedFontSize: 20,
        unselectedFontSize: 15,
        type: BottomNavigationBarType.fixed, //显示三个以上菜单
        fixedColor: Colors.green,
        currentIndex: _currentIndex, //初始页面
        items: const <BottomNavigationBarItem>[
          BottomNavigationBarItem(icon: Icon(Icons.home), label: "首页"),
          BottomNavigationBarItem(icon: Icon(Icons.category), label: "分类"),
          BottomNavigationBarItem(icon: Icon(Icons.shopping_cart), label: "购物车"),
          BottomNavigationBarItem(icon: Icon(Icons.face), label: "我的"),
        ],
        onTap: (value){
          setState(() {
            _currentIndex = value;
          });
        },
      ),
      backgroundColor: Colors.white,

      body: _pages[_currentIndex],
    );
  }

}
